package com.rules.admin.expression;

public class MapExpression implements Expression {
   private String map;
   private String key;
   private String value;
   private String method;

   public MapExpression(String map, String key, String value, String method) {
      this.map = map;
      this.key = key;
      this.value = value;
      this.method = method;
   }

   public void accept(ExpressionVisitor visitor) {
      visitor.vistor((Expression)this);
   }

   public String getMap() {
      return this.map;
   }

   public void setMap(String map) {
      this.map = map;
   }

   public String getKey() {
      return this.key;
   }

   public void setKey(String key) {
      this.key = key;
   }

   public String getValue() {
      return this.value;
   }

   public void setValue(String value) {
      this.value = value;
   }

   public String toString() {
      if ("put".equals(this.method)) {
         return "((Map)(" + this.map + ")).put('" + this.key + "','" + this.value + "')";
      } else {
         return "get".equals(this.method) ? "((Map)(" + this.map + ")).get('" + this.key + "')" : null;
      }
   }
}
